home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Information / Digests / CSMP Digest / volume 1 / csmp-v1-138.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  42.3 KB  |  1,197 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Mon, 13 Jul 92       Volume 1 : Issue 138
  2.  
  3. Today's Topics:
  4.  
  5.     Bug fix for window standard state code
  6.     Faking CustomGetFile under 6.0.x
  7.     Programming C++ on Mac
  8.     XWindows (was - Towards what purpose A/UX?)
  9.     SUMMARY: Comparing blocks of memory in Pascal
  10.  
  11.  
  12.  
  13. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  14.  
  15. The digest is a collection of article threads from the internet newsgroup
  16. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  17. regularly and want an archive of the discussions.  If you don't know what a
  18. newsgroup is, you probably don't have access to it.  Ask your systems
  19. administrator(s) for details.  (This means you can't post questions to the
  20. digest.)
  21.  
  22. Each issue of the digest contains one or more sets of articles (called
  23. threads), with each set corresponding to a 'discussion' of a particular
  24. subject.  The articles are not edited; all articles included in this digest
  25. are in their original posted form (as received by our news server at
  26. cs.uoregon.edu).  Article threads are not added to the digest until the last
  27. article added to the thread is at least one month old (this is to ensure that
  28. the thread is dead before adding it to the digest).  Article threads that
  29. consist of only one message are generally not included in the digest.
  30.  
  31. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  32. [128.223.8.8] in the directory /pub/mac/csmp-digest.  The most recent issues
  33. are available from sumex-aim.stanford.edu [36.44.0.6] in the directory
  34. /info-mac/digest/csmp.  If you don't have ftp capability, the sumex archive
  35. has a mail server; send a message with the text '$MACarch help' (no quotes)
  36. to LISTSERV@ricevm1.rice.edu for more information.
  37.  
  38. These digest is also available via email.  Just send a note saying that you
  39. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  40. automatically receive each new issue as it is created.  Sorry, back issues
  41. are not available through the mailing list.
  42.  
  43. Send administrative mail to mkelly@cs.uoregon.edu.
  44.  
  45.  
  46. -------------------------------------------------------
  47.  
  48. From: zben@ni.umd.edu (Charles B. Cranston)
  49. Subject: Bug fix for window standard state code
  50. Date: 9 Jun 92 21:33:28 GMT
  51. Organization: UM Home for the Terminally Analytical
  52.  
  53. Well, at the time I posted that code I explicitly said it
  54. wasn't perfect, and it sure wasn't.  Sometimes it will zoom
  55. to the wrong monitor.  Here's why:
  56.  
  57. Consider this heterogenous multiple-monitor setup (which happens
  58. to be the setup I am using at work now):
  59.  
  60.  
  61. +----------+ +-------------------------------+
  62. |          | |                               |
  63. |  Apple   | |        Micrographics          |
  64. |   13"    | |         Megascreen            |
  65. |  Color   | |            B/W                |
  66. |          | |                               |
  67. +----------+ |                               |
  68.              |                               |
  69.              |                               |
  70.              |                               |
  71.              |                               |
  72.              +-------------------------------+
  73.  
  74. Now, suppose you have a window that is smaller than its natural
  75. size and split between the monitors, with most of it on the left
  76. (smaller) monitor (note area a is larger than area b).
  77.  
  78. +----------+ +-------------------------------+
  79. |          | |                               |
  80. |      ..........                            |
  81. |      :aaa| |bb:                            |
  82. |      ..........                            |
  83. |          | |                               |
  84. +----------+ |                               |
  85.              |                               |
  86.              |                               |
  87.              |                               |
  88.              |                               |
  89.              +-------------------------------+
  90.  
  91. When you hit the zoom box, the code I posted will zoom to the
  92. RIGHT monitor, rather than to the (expected) left monitor.
  93.  
  94. The reason for this bug is that the expanded natural size
  95. rectangle is being used for the "monitor on which most of the
  96. window resides" instead of the current window rectangle.
  97.  
  98.  
  99. +----------+ +-------------------------------+
  100. |          | |                               |
  101. |      ..........                            |
  102. |      :aaa| |bb:                            |
  103. |      :aaa| |bb:                            |
  104. |      :aaa| |bb:                            |
  105. +------:---+ |bb:                            |
  106.        :     |bb:                            |
  107.        :     |bb:                            |
  108.        ..........                            |
  109.              |                               |
  110.              +-------------------------------+
  111.  
  112.  
  113. Note that area b is now larger than area a (because of the
  114. greater intersection of the hidden window area with the
  115. taller monitor) and so the wrong monitor is choosen.
  116.  
  117.  
  118. Here is the corrected code:
  119.  
  120.  
  121. /* Compute "standard state" for resizable (list) window.
  122.  * This is used by the zooming stuff.
  123.  */
  124. getstdstate(WindowPtr windp, Rect *wrect)
  125. {
  126.     Rect    rect;
  127.     GDHandle    thegd, maingd;
  128.     
  129.     getnaturalsize(windp,wrect);
  130.     if (colorqd) {
  131.     thegd = nil;
  132.     getmonitor(TOPLEFT(*wrect),&thegd);
  133.     if ( (nil==thegd) || !PtInRect(BOTRITE(*wrect),&(**thegd).gdRect) ) {
  134.         thegd = maingd = GetMainDevice();
  135.             getwindowrect(windp,&rect);    /* the fix */
  136.         getmaxmonitor(&rect,&thegd);    /* the fix */
  137.         rect = (**thegd).gdRect;
  138.         rect.top += 16;
  139.         if ( maingd == thegd )
  140.         rect.top += GetMBarHeight();
  141.         InsetRect(&rect,5,5);
  142.         OffsetRect(wrect,rect.left-(*wrect).left,rect.top-(*wrect).top);
  143.         if ( (*wrect).bottom > rect.bottom)
  144.         (*wrect).bottom = rect.bottom;
  145.         else
  146.         OffsetRect(wrect,0,(RECTHITE(rect)-RECTHITE(*wrect))/3);
  147.         if ( (*wrect).right > rect.right)
  148.         (*wrect).right = rect.right;
  149.         else
  150.         OffsetRect(wrect,(RECTWIDE(rect)-RECTWIDE(*wrect))/2,0);
  151.     }
  152.     } else {
  153.     rect = qd.screenBits.bounds;
  154.     if ( !PtInRect(BOTRITE(*wrect),&rect) ) {
  155.         rect.top += 16 + GetMBarHeight();
  156.         InsetRect(&rect,5,5);
  157.         OffsetRect(wrect,rect.left-(*wrect).left,rect.top-(*wrect).top);
  158.         if ( (*wrect).bottom > rect.bottom)
  159.         (*wrect).bottom = rect.bottom;
  160.         else
  161.         OffsetRect(wrect,0,(RECTHITE(rect)-RECTHITE(*wrect))/3);
  162.         if ( (*wrect).right > rect.right)
  163.         (*wrect).right = rect.right;
  164.         else
  165.         OffsetRect(wrect,(RECTWIDE(rect)-RECTWIDE(*wrect))/2,0);
  166.     }
  167.     
  168.     }
  169. }
  170.  
  171.  
  172. Mea Bugga.
  173.  
  174. ---------------------------
  175.  
  176. From: haynes@mace.cc.purdue.edu (Carl W. Haynes III)
  177. Subject: Faking CustomGetFile under 6.0.x
  178. Date: 26 May 92 18:20:30 GMT
  179.  
  180.  
  181. I'm having some trouble duplicating CustomGetFile's functionality 
  182. under System 6.0.X -  Here's the deal:
  183.  
  184. I need to add a "New..." Button to the standard get dialog. Under 
  185. System 7, this is no problem, I call CustomGetFile(), fake a 
  186. cancel Button msg when New is selected and use the yourDataPtr 
  187. parameter to let me know what happened. 
  188.  
  189. Under 6.0.X I use SFPGetFile() to display my new and improved 
  190. standard dlg. I can catch the selection of my New button with 
  191. a dlgHook and can fake the cancel button, 
  192. But I can't figure out a way to return the message that New was 
  193. actually selected rather then Cancel.
  194.  
  195. The two schemes I thought up are:
  196.  
  197. 1) use a global. Easy way out, but messy in the long run. I'm 
  198.    trying to limit the use of globals and I would like a solution 
  199.    that is easy to cut and paste into other applications.
  200.  
  201. 2) Stash the Boolean NewWasPressed into the copy field of the 
  202.    SFReply record (IM I-519 says this field is not used). I don't 
  203.    know how to get access to the record to stash the Boolean there 
  204.    and it will probably break in the future even if I do figure it 
  205.    out.
  206.  
  207. So..... any ideas? Lots of applications do this  (FileMaker Pro, 
  208. Think C, etc) so it can't be that hard. I have the feeling that 
  209. I'm making it harder than it actually is and that I'm missing 
  210. something completely obvious.
  211.  
  212. Any help is appreciated,
  213. carl
  214.  
  215. - --
  216. Carl W. Haynes III  
  217. Haynes Consulting Services        ||  CWH3@aol.com
  218. PO Box 2715                       ||  haynes@mace.cc.purdue.edu
  219. W. Lafayette, IN 47906            ||  voice & fax: 317 463-6383
  220. - ----------------------------------------------------------------------
  221.                   Macintosh Programming & Consulting
  222.  
  223. +++++++++++++++++++++++++++
  224.  
  225. From: d88-jwa@dront.nada.kth.se (Jon W{tte)
  226. Date: 26 May 92 20:18:27 GMT
  227. Organization: Royal Institute of Technology, Stockholm, Sweden
  228.  
  229. .edu> haynes@mace.cc.purdue.edu (Carl W. Haynes III) writes:
  230.  
  231.    1) use a global. Easy way out, but messy in the long run. I'm 
  232.       trying to limit the use of globals and I would like a solution 
  233.       that is easy to cut and paste into other applications.
  234.  
  235. Aimple, clean, and the way Apple does it. Really.
  236.  
  237.    2) Stash the Boolean NewWasPressed into the copy field of the 
  238.       SFReply record (IM I-519 says this field is not used). I don't 
  239.  
  240. Unused == DO NOT USE. Period.
  241.  
  242. Sometimes globals are necessary. Since the SFP is "nice" and
  243. uses no messy interrupt/A5 stuff, you can use globals OK.
  244.  
  245. - -- 
  246. h++ - new and improved !
  247.  
  248. A Bus Station is where buses stop. A Train Station is where
  249. trains stop. On my desk, there is a Work Station.
  250.  
  251. +++++++++++++++++++++++++++
  252.  
  253. From: time@ice.com (Tim Endres)
  254. Date: Wed, 10 Jun 92 09:35:17 EST
  255. Organization: ICE Engineering, Inc.
  256.  
  257.  
  258. In article <D88-JWA.92May26211827@dront.nada.kth.se> (comp.sys.mac.programmer), d88-jwa@dront.nada.kth.se (Jon W{tte) writes:
  259. > Aimple, clean, and the way Apple does it. Really.
  260. >    2) Stash the Boolean NewWasPressed into the copy field of the 
  261. >       SFReply record (IM I-519 says this field is not used). I don't 
  262. > Unused == DO NOT USE. Period.
  263. > Sometimes globals are necessary. Since the SFP is "nice" and
  264. > uses no messy interrupt/A5 stuff, you can use globals OK.
  265.  
  266. What about the Dialog Filter Approach. Define your own SFReply:
  267.  
  268.     struct MySFReply {
  269.         SFReply        sfr;
  270.         int            myflag;
  271.         }
  272.  
  273. And passing the pointer to this structre to SFGetFile().
  274. This way the SFReply structure is unadulterated, and you can
  275. append any amount of data you want. You get the pointer in your
  276. filter, and no globals.
  277.  
  278.  
  279. tim endres - time@ice.com  -or-  uupsi!tbomb!time
  280. ICE Engineering, Inc. - Phone (313) 449 8288 - FAX (313) 449-9208
  281. 8840 Main Street, Whitmore Lake, MI  48189
  282. USENET - a slow moving self parody... ph
  283.  
  284. +++++++++++++++++++++++++++
  285.  
  286. From: keith@taligent.com (Keith Rollin)
  287. Date: 10 Jun 92 21:22:18 GMT
  288. Organization: Taligent
  289.  
  290. In article <1CE00001.5mval1@tbomb.ice.com>, time@ice.com (Tim Endres) writes:
  291. > In article <D88-JWA.92May26211827@dront.nada.kth.se>
  292. (comp.sys.mac.programmer), d88-jwa@dront.nada.kth.se (Jon W{tte) writes:
  293. > > Aimple, clean, and the way Apple does it. Really.
  294. > > 
  295. > >    2) Stash the Boolean NewWasPressed into the copy field of the 
  296. > >       SFReply record (IM I-519 says this field is not used). I don't 
  297. > > 
  298. > > Unused == DO NOT USE. Period.
  299. > > 
  300. > > Sometimes globals are necessary. Since the SFP is "nice" and
  301. > > uses no messy interrupt/A5 stuff, you can use globals OK.
  302. > What about the Dialog Filter Approach. Define your own SFReply:
  303. >     struct MySFReply {
  304. >         SFReply        sfr;
  305. >         int            myflag;
  306. >         }
  307. > And passing the pointer to this structre to SFGetFile().
  308. > This way the SFReply structure is unadulterated, and you can
  309. > append any amount of data you want. You get the pointer in your
  310. > filter, and no globals.
  311. >
  312.  
  313. You know, sometimes I wonder if I'm missing something with this approach.
  314. Someone else suggested it to me, and I fell for it. Only later did I remember
  315. that the dlgHook is _not_ passed a pointer to the reply record. It is passed an
  316. item number (which could be a psuedo-item number) and a DialogPtr.
  317.  
  318. Now you suggest the same thing, and I wonder if I'm missing something.
  319.  
  320. - --
  321. Keith Rollin
  322. Phantom Programmer
  323. Taligent, Inc.
  324.  
  325. ---------------------------
  326.  
  327. From: lam@saifr00.cfsat.honeywell.com (Josh Lam)
  328. Subject: Programming C++ on Mac
  329. Date: 27 May 92 17:39:46 GMT
  330. Organization: Honeywell Air Transport Systems Division
  331.  
  332. Hi,
  333.  
  334. I am extremely new to C++ in the Mac environment.  I  will be soon learning
  335. C++ on a PC at my place of work using Borland C++ and Turbo C++. However, I
  336. have a Mac IIsi at home and would like to learn C++ at home after office
  337. hours. 
  338.  
  339. I am hoping to get a C++ compiler for my Mac and I noticed, as I
  340. browsed throught this newsgroup that there are two commonly mentioned C++
  341. compilers for the Mac, namely MPW C++ and Zortech C++.  It would be nice if 
  342. I can run Turbo C++ or Borland C++ (maybe via SoftPC of which I do not know
  343. much about.  I was told it can be slow) so I can be more consistent with my
  344. work.  Has anyone tried that?
  345.  
  346. I would appreciate any advice on this matter.
  347.  
  348. Also how can I get MPW C++?  Are there any books out there on programming
  349. with C++ on the Mac?  I checked out the local bookstores but found none.
  350.  
  351. Thanks in advance.
  352.  
  353. Josh Lam
  354. Honeywell Inc
  355. lam@saifr00.cfsat.honeywell.com
  356.  
  357. - -- 
  358. Josh Lam
  359. Honeywell Inc
  360. lam@saifr00.cfsat.honeywell.com
  361.  
  362. +++++++++++++++++++++++++++
  363.  
  364. From: jleuper@lotus.com (Jim Leuper)
  365. Organization: Lotus Development Corp.
  366. Date: Mon, 8 Jun 92 16:04:03 GMT
  367.  
  368. > It would be nice if 
  369. > I can run Turbo C++ or Borland C++ (maybe via SoftPC of which I do not know
  370. > much about.  I was told it can be slow) so I can be more consistent with my
  371. > work.  Has anyone tried that?
  372.  
  373. Hmmm... a comment on the nature of compilers. You might be able to get Turbo
  374. C++ or Borland C++ to run on your Mac under SoftPC, but they won't do what you
  375. are hoping for. They are designed to emit code that will run on IBM PC's,
  376. and they will continue to do so even if you manage to run them on a Mac. This
  377. is what people are speaking of when they refer to cross-compilation.
  378. If you expect to run the programs on your Mac, you will need a native compiler.
  379.  
  380. > Also how can I get MPW C++?  Are there any books out there on programming
  381. > with C++ on the Mac?  I checked out the local bookstores but found none.
  382.  
  383. MPW C++ is an Apple product, available from APDA  (Apple Programmers and
  384. Developers Association). Their phone number is 1-800-282-APDA.
  385. I know of at least one book that fits the bill. It is entitled "Elements of
  386. C++ Programming on the Macintosh" (or something reasonably close). It is
  387. published by Addison-Wesley, and I believe that the author's name is
  388. Weston.
  389.  
  390. - ----------------------------------------------------------------
  391. Jim Leuper                         Lotus Development Corporation
  392. jleuper@lotus.com                      Advanced Technology Group
  393. - ----------------------------------------------------------------
  394.  
  395. +++++++++++++++++++++++++++
  396.  
  397. From: potts@itl.itd.umich.edu (Paul Potts)
  398. Organization: Instructional Technology Laboratory, University of Michigan
  399. Date: Mon, 8 Jun 92 19:22:57 GMT
  400.  
  401. In article <1992Jun8.160403.10740@lotus.com> jleuper@lotus.com (Jim Leuper) writes:
  402. >> It would be nice if 
  403. >> I can run Turbo C++ or Borland C++ (maybe via SoftPC of which I do not know
  404. >> much about.  I was told it can be slow) so I can be more consistent with my
  405. >> work.  Has anyone tried that?
  406. >
  407. >Hmmm... a comment on the nature of compilers. You might be able to get Turbo
  408. >C++ or Borland C++ to run on your Mac under SoftPC, but they won't do what you
  409. >are hoping for. They are designed to emit code that will run on IBM PC's,
  410.  
  411. Has anyone reading done this (gotten Borlanc C++ or another DOS-based
  412. C++ compiler to run under SoftPC on the Mac?  Yes, I know it would produce
  413. code that runs under DOS. I'm just wondering if anyone has successfully
  414. gotten one of these setups to work. Does SoftPC support EMS and XMS memory?
  415.  
  416. ... curious for more than academic reasons...
  417.  
  418. - -- 
  419. The essence of OOP: "With all this horse manure, I know there's got to be
  420.                      a pony in here somewhere!"
  421. Paul R. Potts, Software Designer --- potts@itl.itd.umich.edu <--- me!
  422.  
  423. +++++++++++++++++++++++++++
  424.  
  425. From: trimper@edsi.plexus.COM (Greg Trimper)
  426. Date: 9 Jun 92 04:11:03 GMT
  427. Organization: Enterprise Data Systems Incorporated, Appleton WI
  428.  
  429. potts@itl.itd.umich.edu (Paul Potts) writes:
  430.  
  431. >Has anyone reading done this (gotten Borlanc C++ or another DOS-based
  432. >C++ compiler to run under SoftPC on the Mac?  Yes, I know it would produce
  433. >code that runs under DOS. I'm just wondering if anyone has successfully
  434. >gotten one of these setups to work. Does SoftPC support EMS and XMS memory?
  435.  
  436. SoftAT does support extra memory, I do not know about SoftPC.  I have
  437. successfully written and compiled programs with Turbo Pascal Pro and
  438. Turbo Vision under SoftAT - I would imagine the others would work as
  439. well.  It is slow, yes, but it also works in the background - doing background
  440. compiles of PC programs on my SE/30 while working in MPW just sorta gives me
  441. a thrill, if you know what I am saying...  smiley.
  442.  
  443. Also, you CAN install DOS 5 and Win3, if you are careful.  DOn't bother
  444. with Win3 except just as a way to make you Big Blue Friends ooh and ah
  445. over the versatility - it is toooooooo slow to be useable.
  446.  
  447.  
  448. Greg Trimper   trimper@edsi.plexus.com  
  449.  
  450. +++++++++++++++++++++++++++
  451.  
  452. From: nagle@netcom.com (John Nagle)
  453. Date: Wed, 10 Jun 92 16:21:53 GMT
  454. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  455.  
  456. trimper@edsi.plexus.COM (Greg Trimper) writes:
  457. >SoftAT does support extra memory, I do not know about SoftPC.  I have
  458. >successfully written and compiled programs with Turbo Pascal Pro and
  459. >Turbo Vision under SoftAT - I would imagine the others would work as
  460. >well.  It is slow, yes, but it also works in the background - doing background
  461. >compiles of PC programs on my SE/30 while working in MPW just sorta gives me
  462. >a thrill, if you know what I am saying...  smiley.
  463.  
  464.        SoftAT is impressive.  It's so compatible PC viruses can run under it.
  465.  
  466.        Incidentally, SoftVGA is out for Sparc-based machines.  Macs 
  467. may be supported later.
  468.  
  469.                     John Nagle
  470.  
  471. ---------------------------
  472.  
  473. From: rae@alias.com (Reid Ellis)
  474. Subject: XWindows (was - Towards what purpose A/UX?)
  475. Organization: Alias Research, Inc., Toronto ON Canada
  476. Date: Tue, 2 Jun 1992 04:11:50 GMT
  477.  
  478. Tim Endres <time@ice.com> writes:
  479. |XWindows is great for the purpose it was intended. I see NO OTHER
  480. |network based windowing system on the planet that compares to X.
  481.  
  482. Jon W{tte <d88-jwa@dront.nada.kth.se> writes:
  483. |QuickDraw GX. 'nuff said.
  484.  
  485. This is the first I've heard of QDGX being "network based".  Has this
  486. been mentioned somewhere and I just missed it?  Developer's Conference
  487. maybe?
  488.  
  489. Reid
  490.  
  491. [PS: Follow-ups directed to comp.sys.mac.programmer]
  492. - --
  493. Reid Ellis                                            
  494. rae@utcs.utoronto.ca        ||           rae@Alias.com
  495. CDA0610@applelink.apple.com ||  +1 416 362 9181 [work]
  496.  
  497. +++++++++++++++++++++++++++
  498.  
  499. From: ksand@apple.com (Kent Sandvik)
  500. Date: 7 Jun 92 01:03:00 GMT
  501. Organization: MacDTS Mongols
  502.  
  503. In article <1992Jun2.041150.25536@alias.com>, rae@alias.com (Reid Ellis) writes:
  504. > Tim Endres <time@ice.com> writes:
  505. > |XWindows is great for the purpose it was intended. I see NO OTHER
  506. > |network based windowing system on the planet that compares to X.
  507.  
  508. > Jon W{tte <d88-jwa@dront.nada.kth.se> writes:
  509. > |QuickDraw GX. 'nuff said.
  510.  
  511. > This is the first I've heard of QDGX being "network based".  Has this
  512. > been mentioned somewhere and I just missed it?  Developer's Conference
  513. > maybe?
  514.  
  515. QDGX is not network based, thank God. We don't need a yet another slow 
  516. graphics system. Whoever thought that sending bitmaps over the network
  517. is a good idea should take a long deep breath.
  518. - --
  519.                                               Cheers, Kent
  520.  
  521.  
  522. +++++++++++++++++++++++++++
  523.  
  524. From: mlanett@Apple.COM (Mark Lanett)
  525. Date: 7 Jun 92 01:26:20 GMT
  526. Organization: Apple Computer Inc., Cupertino, CA
  527.  
  528. ksand@apple.com (Kent Sandvik) writes:
  529.  
  530. >In article <1992Jun2.041150.25536@alias.com>, rae@alias.com (Reid Ellis) writes:
  531. >> Tim Endres <time@ice.com> writes:
  532. >> |XWindows is great for the purpose it was intended. I see NO OTHER
  533. >> |network based windowing system on the planet that compares to X.
  534.  
  535. NeXTStep is also networked... pipe that PostScript over the ether, baby.
  536. - -- 
  537. Have a bajillion brilliant Jobsian lithium licks.
  538. Mark Lanett - personal {opinions,ramblings,hallucinations}
  539. - -- 
  540. Have a bajillion brilliant Jobsian lithium licks.
  541. Mark Lanett - personal {opinions,ramblings,hallucinations}
  542.  
  543. +++++++++++++++++++++++++++
  544.  
  545. From: ksand@apple.com (Kent Sandvik)
  546. Date: 7 Jun 92 03:40:38 GMT
  547. Organization: MacDTS Mongols
  548.  
  549. In article <68299@apple.Apple.COM>, mlanett@Apple.COM (Mark Lanett) writes:
  550. > ksand@apple.com (Kent Sandvik) writes:
  551. > >In article <1992Jun2.041150.25536@alias.com>, rae@alias.com (Reid Ellis)
  552. writes:
  553. > >> Tim Endres <time@ice.com> writes:
  554. > >> |XWindows is great for the purpose it was intended. I see NO OTHER
  555. > >> |network based windowing system on the planet that compares to X.
  556. > NeXTStep is also networked... pipe that PostScript over the ether, baby.
  557.  
  558. And NeWS designers also realized that vectorized information is far faster to
  559. pump
  560. over the net than slow bitmaps. Anyway, I personally think that graphics
  561. networking is really not a big issue. This based on the experience seeing
  562. Habitat (one of the first crude virtual reality systems) running over
  563. a 300bps modem, and a Commodore-64 was doing the graphics. It's all in 
  564. the protocol, boys and girls. Graphics is best done on the display/CPU
  565. itself. This is something Silicon Graphics also knows.
  566. - --
  567.                                               Cheers, Kent
  568.  
  569.  
  570. +++++++++++++++++++++++++++
  571.  
  572. From: oster@well.sf.ca.us (David Phillip Oster)
  573. Date: 7 Jun 92 09:52:35 GMT
  574. Organization: Whole Earth 'Lectronic Link
  575.  
  576. In article <68299@apple.Apple.COM> mlanett@Apple.COM (Mark Lanett) writes:
  577. _>ksand@apple.com (Kent Sandvik) writes:
  578. _>>In article <1992Jun2.041150.25536@alias.com>, rae@alias.com (Reid Ellis) writes:
  579. _>>> Tim Endres <time@ice.com> writes:
  580. _>>> |XWindows is great for the purpose it was intended. I see NO OTHER
  581. _>>> |network based windowing system on the planet that compares to X.
  582. _>NeXTStep is also networked... pipe that PostScript over the ether, baby.
  583. Silicon Graphics's network version of its "gl" graphic library lets you ship
  584. shaded, lit, 3-d models with textured spline surfaces and Z-buffering over the
  585. net. Kind of hard to do that with either QuickDraw or Postscript.
  586.  
  587. +++++++++++++++++++++++++++
  588.  
  589. From: ksand@apple.com (Kent Sandvik)
  590. Date: 8 Jun 92 03:09:27 GMT
  591. Organization: MacDTS Mongols
  592.  
  593. In article <1992Jun7.095235.17482@well.sf.ca.us>, oster@well.sf.ca.us (David
  594. Phillip Oster) writes:
  595. > In article <68299@apple.Apple.COM> mlanett@Apple.COM (Mark Lanett) writes:
  596. > _>ksand@apple.com (Kent Sandvik) writes:
  597. > _>>In article <1992Jun2.041150.25536@alias.com>, rae@alias.com (Reid Ellis)
  598. writes:
  599. > _>>> Tim Endres <time@ice.com> writes:
  600. > _>>> |XWindows is great for the purpose it was intended. I see NO OTHER
  601. > _>>> |network based windowing system on the planet that compares to X.
  602. > _>NeXTStep is also networked... pipe that PostScript over the ether, baby.
  603. > Silicon Graphics's network version of its "gl" graphic library lets you ship
  604. > shaded, lit, 3-d models with textured spline surfaces and Z-buffering over the
  605. > net. Kind of hard to do that with either QuickDraw or Postscript.
  606.  
  607. OK, I guess I need to justify why I personally think that distributed graphics
  608. are evil, even if handy in some instances. Imagine user Foo Bar, sitting by
  609. his/her computer, which suddenly starts acting sluggish. The end user will maybe
  610. reboot the machine, or try to shake it, or call the service technician.
  611.  
  612. Little did they know that a client used CPU cycles over the net for nifty
  613. 3-D graphics that the manager needs for his multimedia presentation next 
  614. Friday.
  615.  
  616. It's fine to use such power for special projects, let's say "Industrial Light
  617. and Magic" style graphics shops. However distributed graphics computing is a
  618. little bit
  619. scary as a default setup for office computers. Most end users enjoy the
  620. snappiness
  621. of fast graphics, and they don't want anything happening behind their backs for 
  622. decreasing the graphics performance. This is the reason multi-user UNIX systems
  623. never sell/perform well in the office environment (trust me, I looked with my
  624. left 
  625. eye when sales reps tried to sell 'em).
  626. - --
  627.                                               Cheers, Kent
  628. PS: Personal comments.
  629.  
  630.  
  631. +++++++++++++++++++++++++++
  632.  
  633. From: Thad.Humphries@p950.f70.n109.z1.fidonet.org (Thad Humphries)
  634. Date: 9 Jun 92 02:27:20 GMT
  635.  
  636.  
  637.   KS> From: ksand@apple.com (Kent Sandvik) Newsgroups:
  638.   KS> comp.sys.mac.programmer Organization: MacDTS Mongols
  639.   KS> 
  640.   KS> In article <1992Jun7.095235.17482@well.sf.ca.us>, oster@well.sf.ca.us
  641.   KS> (David Phillip Oster) writes:
  642.   KS> 
  643.  
  644.   > In article <68299@apple.Apple.COM> mlanett@Apple.COM (Mark Lanett)
  645.   > writes:
  646.   _> ksand@apple.com (Kent Sandvik) writes:
  647.   > In article <1992Jun2.041150.25536@alias.com>, rae@alias.com (Reid Ellis)
  648.   KS> writes:
  649.   > Tim Endres <time@ice.com> writes: |XWindows is great for the purpose it
  650.   > was intended. I see NO OTHER |network based windowing system on the
  651.   > planet that compares to X.
  652.  
  653.   KS> OK, I guess I need to justify why I personally think that distributed
  654.   KS> graphics are evil, even if handy in some instances.
  655.  
  656. In the "for what it's worth department, my biggest reason for *not* getting A/UX
  657. (except my savings still thin from all last year's new toys) is the X
  658. environment.  Why do I want a Mac window manager?  I want Unix and X but not if
  659. I can't have Motif.  ICS has Motif for A/UX 2.0 but at a heafty price.  Why
  660. can't Apple bundle an industry standard window manager with development
  661. libraries?
  662.  
  663. ---------------------------
  664.  
  665. From: stanger@otago.ac.nz (Nigel Stanger)
  666. Subject: SUMMARY: Comparing blocks of memory in Pascal
  667. Date: 5 Jun 92 02:18:10 GMT
  668. Organization: University of Otago, Dunedin, New Zealand
  669.  
  670. Well, I received lots of replies on how to compare two blocks of
  671. memory, the end result being I now have a function that will work
  672. for arbitrary-sized blocks. The function goes something like this
  673. (thanks to Doug McNaught and Jim Cathey):
  674.  
  675.   function MemEqual(a,b: Ptr; n:integer):Boolean;
  676.   var i:integer;
  677.       p1,p2:Ptr;
  678.   begin
  679.     p1:=a;
  680.     p2:=b;
  681.     for i:=1 to n do begin
  682.       if (p1^ <> p2^) then begin
  683.         MemEqual = FALSE;
  684.         Exit(MemEqual)
  685.       end else begin
  686.         p1 := Ptr(ord4(p1) + 1);
  687.         p2 := Ptr(ord4(p2) + 1);
  688.       end
  689.     end;
  690.     MemEqual := TRUE;
  691.   end; {MemEqual}
  692.  
  693. As you can see, it's basically just a Pascal implementation of C
  694. pointer arithmetic. I think you can get away with not using p1
  695. and p2 -- just access a and b directly instead. This assumes of
  696. course that you are passing the addresses of the objects rather
  697. than actual Ptrs, i.e. MemEqual(@obj1,@obj2,size). If you were
  698. passing Ptrs things could get messy later on... :)
  699.  
  700. However, one proviso to go with this -- as quinn@cs.uwa.edu.au
  701. points out:
  702. > The reason Pascal doesn't support comparing structured types is that
  703. > not all the bits in a record or array are necessarily significant.
  704. > For example:
  705. >
  706. >   type
  707. >     a = record
  708. >         b : boolean;
  709. >         c : char;
  710. >         d : boolean;
  711. >       end;
  712. >
  713. > Acording to Think Pascal this has a size of 6.  Now there are only
  714. > 3 bytes of real data in there so you're left with 3 bytes of rubbish.
  715. > If you do a memory image compare you're going to be mislead, if
  716. > not now then some time soon.
  717. >
  718. > Of course if you stick to nice types like integer, longint, OSType,
  719. > etc (things that are word sized or even multiples thereof) you'll
  720. > be OK.  Things to be careful of are char, byte, signedByte, boolean,
  721. > subranges, and arrays.  Also remember that if you make your records
  722. > packed then all these rules change!
  723.  
  724. This isn't a problem in my case, as I read the data from a
  725. resource. Although there _is_ an odd byte in there, the ResEdit
  726. template I created for the resource has an FBYT there, which
  727. automatically fills it in zero when I create one. I can see that
  728. this would be a problem in general though. Would blanking (i.e.
  729. fill with zeros) the block of memory beforehand help? I might try
  730. this out and see what happens.
  731.  
  732. Matt Mora suggested:
  733. > IUMagIDString(aPtr,bPtr:Ptr;aLen,bLen:INTEGER):INTEGER;
  734. >
  735. > It will compare blocks of memory and return a 0 if they are equal else
  736. > it return a 1.
  737.  
  738. However, Jon Waette (sp?) points out that "IU means that it will
  739. do some strange stuff with international characters..."
  740.  
  741. Tommy Nordgren suggested using Munger. I had thought of that, but
  742. I've never really sat down and tried to figure what it is that
  743. Munger actually _does_. I seem to remember that it does something
  744. different, but I could be wrong. Oh well... He also suggested
  745. looking at the source code for the HexDump DA -- haven't done
  746. this yet, but will do...
  747.  
  748. Phil Shapiro suggested EqualMem() from the TCL library. I'd
  749. forgotten about that one -- written in assembly too. It is
  750. limited to 32K, and the size of the object must be even. The big
  751. problem I found with this was actually including it in my project
  752. - -- I seemed to end up needing a whole pile of files in the
  753. project that I didn't really want (this is a non-TCL app BTW).
  754. Maybe I just did it wrong...
  755.  
  756. That's the options I got, the first option seems to work OK, and
  757. has certainly solved my current problem. Thanks to everyone who
  758. contributed!
  759.  
  760. - -- 
  761. See ya
  762.                                 Nigel.
  763. - ----------------------------------------------------------------------
  764. Nigel Stanger,                  Internet: stanger@otago.ac.nz
  765. University of Otago,            Phone: +64 3 479-8179
  766. Dunedin, NEW ZEALAND.           Fax:   +64 3 479-8311
  767. "I would like to propose a toast -- to the caterers!" -- Rowan Atkinson
  768.  
  769. +++++++++++++++++++++++++++
  770.  
  771. From: siegel@world.std.com (Rich Siegel)
  772. Date: 5 Jun 92 13:39:16 GMT
  773. Organization: GCC Technologies
  774.  
  775. In article <1992Jun5.151810.2887@otago.ac.nz> stanger@otago.ac.nz (Nigel Stanger) writes:
  776. >
  777. >  function MemEqual(a,b: Ptr; n:integer):Boolean;
  778. >
  779. >Phil Shapiro suggested EqualMem() from the TCL library. I'd
  780. >forgotten about that one -- written in assembly too. It is
  781. >limited to 32K, and the size of the object must be even. The big
  782.  
  783.     Your homegrown EqualMem is limited to 32K as well, because both
  784. the argument 'n' and the local counter 'i' are 16-bit integers.
  785.  
  786.     Also, you can get a considerable speed improvement by comparing
  787. more than a byte at a time. Such a function would go something like this:
  788. (it's early, so this may not compile, or even work right, the first time)
  789.  
  790. function EqualMem(a, b : univ Ptr; blkSize : LongInt) : Boolean;
  791. var
  792.     longCount : LongInt;
  793.     byteCount : SignedByte;
  794.  
  795.     longIndex : LongInt;
  796.     shortIndex : SignedByte;
  797.  
  798. { byteCount is a SignedByte because we're guaranteed that it's 0 <= n <= 3. }
  799.  
  800. begin
  801.     longCount := blkSize div 4;
  802.     byteCount := blkSize - (longCount * SizeOf(LongInt));
  803.  
  804.     for longIndex := 0 to longCount - 1 do begin
  805.  
  806.         if (LongIntPtr(a)^ <> LongIntPtr(b)^) then begin
  807.             EqualMem := False;
  808.             Exit(EqualMem);
  809.         end;
  810.  
  811.         a := Pointer(Ord4(a) + SizeOf(LongInt));
  812.         b := Pointer(Ord4(b) + SizeOf(LongInt));
  813.     end;
  814.  
  815.     { at this point, the blocks are still equal, so compare the last 
  816.     few bytes }
  817.  
  818.     for shortIndex := 0 to byteCount - 1 do begin
  819.  
  820.         if (a^ <> b^) then begin
  821.             EqualMem := False;
  822.             Exit(EqualMem);
  823.         end;
  824.  
  825.         a := Pointer(Ord4(a) + 1);
  826.         b := Pointer(Ord4(b) + 1);
  827.     end;
  828.  
  829.     { the blocks are *still* equal, so they compare the same }
  830.  
  831.     EqualMem := TRUE;
  832. end;
  833.  
  834. A caveat: if you're comparing two structures (local records, pointers allocated
  835. with NewPtr, handles allocated with NewHandle), this routine is fine. If 
  836. you're comparing two random pointers in memory, then you'll have to change
  837. the routine a bit, because it expects the two blocks being compared to 
  838. begin on even byte boundaries; if they don't, you'll get an Odd Address 
  839. Exception on 68000 machines. This can be avoided by doing a little pre-
  840. processing before the two compare loops, but it does complicate the issue
  841. a bit.
  842.  
  843. >-- I seemed to end up needing a whole pile of files in the
  844. >project that I didn't really want (this is a non-TCL app BTW).
  845. >Maybe I just did it wrong...
  846.  
  847.     You did it wrong; EqualMem is a little black box in the TCL,
  848. which doesn't require any other declarations or services; if you just
  849. copy the function into a separate file, you should be able to use
  850. it by itself.
  851.  
  852. R.
  853.  
  854.  
  855.  
  856. - -- 
  857. - -----------------------------------------------------------------------
  858. Rich Siegel                              Internet: siegel@world.std.com
  859. Software Engineer & Toolsmith
  860. GCC Technologies
  861.  
  862. +++++++++++++++++++++++++++
  863.  
  864. From: paul@cthq.UUCP (Paul G. Smith)
  865. Date: 6 Jun 92 00:39:19 GMT
  866. Organization: CommsTalk HQ
  867.  
  868.  
  869. In article <1992Jun5.151810.2887@otago.ac.nz> (comp.sys.mac.programmer), stanger@otago.ac.nz (Nigel Stanger) writes:
  870. > Well, I received lots of replies on how to compare two blocks of
  871. > memory, the end result being I now have a function that will work
  872. > for arbitrary-sized blocks. The function goes something like this
  873. > (thanks to Doug McNaught and Jim Cathey):
  874.  
  875. I missed your earlier posting(s). Here's my solution (MPW Assembler):
  876.  
  877.  
  878.     ;---------------------------------------------------------------
  879.     ; FUNCTION EQUAL_MEM(buffptr1: Pointer; buffptr1: Pointer; 
  880.     ;                        dataLen: INTEGER;): INTEGER;
  881.     ;---------------------------------------------------------------
  882.     ;
  883.     ;    compares memory: returns 1 if equal, and 0 if not
  884.     ;
  885.     
  886. EQUAL_MEM:    PROC    EXPORT
  887.         
  888.         MOVEA.L (SP)+, A1       ; pop return address
  889.         MOVE.W  (SP)+,D0        ; data length
  890.         MOVE.L  (SP)+,D1        ; data address2
  891.         MOVE.L  (SP)+,A0        ; data address1
  892.         MOVEM.L A1/D1-D3, -(SP) ; save return address again
  893.             
  894.         movea.l    d1,a1            ; copy data address2 into a1
  895.         move.w    d0,d1            ; copy data length
  896.         beq.s    exit            ; skip if zero - result will be set to 0, not equal
  897.         
  898.         clr.w    d0                ; initialise result to not equal
  899.         subq.w    #1,d1            ; decrement count for DBRA
  900. loop:    cmp.b    (a1)+,(a0)+        ; check string bytes
  901.         bne.s    exit            ; skip out if not equal
  902.         dbra    d1,loop            ; loop if more bytes
  903. noDiffs:
  904.         move.w    #1,d0            ; set result to 1 - strings are equal
  905. exit:
  906.         MOVEM.L (SP)+,A1/D1-D3  ; pop return address again
  907.         MOVE.W    D0,-(SP)        ; save result
  908.         JMP     (A1)            ; & split
  909.  
  910.     ENDPROC
  911.  
  912.  
  913.  
  914. It's acceptably (ie, very) fast. :-)
  915.  
  916.  
  917. best regards, Paul
  918.  
  919. - -------------------------------------
  920. Paul G Smith / CommsTalk HQ
  921. INTERNET:  "paul@cthq.uucp"            CIX:  "pgsmith"
  922. AppleLink: "commstalk.hq" ("commstalk.hq@applelink.apple.com")
  923. tel/fax:   + 44 491 574295  (dial 11 on 2nd dial tone for fax)
  924. snail:    40 St Marks Road, Henley-on-Thames, Oxon. RG9 1LW. UK
  925.  
  926. +++++++++++++++++++++++++++
  927.  
  928. From: buckeye@spf.trw.com (John Wallace)
  929. Organization: TRW Data Systems Center, Redondo Beach, CA
  930. Date: Mon, 8 Jun 92 19:23:49 GMT
  931.  
  932. In article <D2150057.5aujva@cthq.UUCP> paul@cthq.uucp writes:
  933. >
  934. >In article <1992Jun5.151810.2887@otago.ac.nz> (comp.sys.mac.programmer), stanger@otago.ac.nz (Nigel Stanger) writes:
  935. >> Well, I received lots of replies on how to compare two blocks of
  936. >> memory, the end result being I now have a function that will work
  937. >> for arbitrary-sized blocks. The function goes something like this
  938. >> (thanks to Doug McNaught and Jim Cathey):
  939. >> 
  940. >
  941. >I missed your earlier posting(s). Here's my solution (MPW Assembler):
  942. >
  943. >
  944. >    ;---------------------------------------------------------------
  945. >    ; FUNCTION EQUAL_MEM(buffptr1: Pointer; buffptr1: Pointer; 
  946. >    ;                        dataLen: INTEGER;): INTEGER;
  947. >    ;---------------------------------------------------------------
  948. >    ;
  949. >    ;    compares memory: returns 1 if equal, and 0 if not
  950. >    ;
  951. >    
  952. >EQUAL_MEM:    PROC    EXPORT
  953. >        
  954. >        MOVEA.L (SP)+, A1       ; pop return address
  955. >        MOVE.W  (SP)+,D0    ; data length
  956. >        MOVE.L  (SP)+,D1    ; data address2
  957. >        MOVE.L  (SP)+,A0    ; data address1
  958. >        MOVEM.L A1/D1-D3, -(SP) ; save return address again
  959. >            
  960. >        movea.l    d1,a1        ; copy data address2 into a1
  961. >        move.w    d0,d1        ; copy data length
  962. >        beq.s    exit        ; skip if zero - result will 
  963. >                    ;   be set to 0, not equal
  964. >        
  965. >        clr.w    d0        ; initialise result to not equal
  966. >        subq.w    #1,d1        ; decrement count for DBRA
  967. >loop:        cmp.b    (a1)+,(a0)+    ; check string bytes
  968. >        bne.s    exit        ; skip out if not equal
  969. >        dbra    d1,loop        ; loop if more bytes
  970. >noDiffs:
  971. >        move.w    #1,d0        ; set result to 1 - strings are equal
  972. >exit:
  973. >        MOVEM.L (SP)+,A1/D1-D3  ; pop return address again
  974. >        MOVE.W    D0,-(SP)    ; save result
  975. >        JMP     (A1)            ; & split
  976. >
  977. >    ENDPROC
  978. >
  979. >
  980. >
  981. >It's acceptably (ie, very) fast. :-)
  982. >
  983. >
  984. >Paul G Smith / CommsTalk HQ
  985. >INTERNET:  "paul@cthq.uucp"            CIX:  "pgsmith"
  986. >AppleLink: "commstalk.hq" ("commstalk.hq@applelink.apple.com")
  987. >tel/fax:   + 44 491 574295  (dial 11 on 2nd dial tone for fax)
  988. >snail:    40 St Marks Road, Henley-on-Thames, Oxon. RG9 1LW. UK
  989.  
  990.  
  991.  
  992. You could make it noticably faster (30%) if you recode the inner loop as:
  993.  
  994. loop:        cmp.b    (a1)+,(a0)+    ; check string bytes
  995.         dbne    d1,loop        ; loop if more bytes
  996.         bne.s    exit        ; if not true, skip setting 1 
  997. noDiffs:
  998.         move.w    #1,d0        ; set result to 1 - strings are equal
  999. exit:
  1000.  
  1001. Since the dbCC instruction can do the job of both loop control
  1002. and condition-code checking, you only have to do the 'bne.s exit'
  1003. after you fall out of the loop.
  1004.  
  1005.  
  1006. You could also re-code it so that it doesn't use the MOVEM instruction
  1007. (since you don't need to put your parameters back on the stack),
  1008. and uses the sCC instruction to compute your results.  These will make 
  1009. especially noticable improvements when comparing only small bits of data:
  1010.  
  1011.     ;---------------------------------------------------------------
  1012.     ; FUNCTION EQUAL_MEM(buffptr1: Pointer; buffptr1: Pointer; 
  1013.     ;     dataLen: INTEGER;): INTEGER;
  1014.     ;---------------------------------------------------------------
  1015.     ;
  1016.     ;    compares memory: returns 1 if equal, and 0 if not
  1017.     ;
  1018.     
  1019. EQUAL_MEM:    PROC    EXPORT
  1020.         
  1021.         move.l  (sp)+,d1       ; pop return address
  1022.         move.w  (sp)+,d0    ; data length
  1023.         move.l  (sp)+,a1    ; data address2
  1024.         move.l  (sp)+,a0    ; data address1
  1025.             
  1026.         subq.w    #1,d0        ; decrement count for loop
  1027.         bmi.s    setResult    ; if length=0, set result to 0
  1028. loop:        cmp.b    (a1)+,(a0)+    ; check string bytes
  1029.         dbne    d0,loop        ; loop if bytes were equal and
  1030.                     ;   there are more bytes to go
  1031. setResult:
  1032.         seq    d0        ; set to -1 if equal, 0 if not equal
  1033.         neg    d0        ; convert to 1 or leave as 0
  1034.  
  1035.         move.w    d0,(SP)        ; save result
  1036.         move    d1,a0        ; get return address
  1037.         jmp     (a0)            ; return
  1038.  
  1039.     ENDPROC
  1040.  
  1041.  
  1042. You could optimize the above even further by checking for zero-length
  1043. compares as soon as you pop dataLen into d0 and jumping to another
  1044. return section, but I didn't bother with that above.  There are
  1045. probably even more optimizations using long-word compares and the
  1046. like, but then you'd have to deal with all of the alignment issues.
  1047.  
  1048.  
  1049. Sorry for rambling on so, but I do enjoy optimizing assembly code!
  1050.  
  1051. Cheers,
  1052. John
  1053.  
  1054. - ---
  1055. John Wallace    buckeye@spf.trw.com
  1056.  
  1057. +++++++++++++++++++++++++++
  1058.  
  1059. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  1060. Date: 9 Jun 92 11:45:44 +1200
  1061. Organization: University of Waikato, Hamilton, New Zealand
  1062.  
  1063. In article <D2150057.5aujva@cthq.UUCP>, paul@cthq.UUCP (Paul G. Smith) writes:
  1064. >
  1065. >     ;---------------------------------------------------------------
  1066. >     ; FUNCTION EQUAL_MEM(buffptr1: Pointer; buffptr1: Pointer;
  1067. >     ;                        dataLen: INTEGER;): INTEGER;
  1068. >     ;---------------------------------------------------------------
  1069. >     ;
  1070. >     ;    compares memory: returns 1 if equal, and 0 if not
  1071. >     ;
  1072. >
  1073. > EQUAL_MEM:    PROC    EXPORT
  1074. >
  1075. >         MOVEA.L (SP)+, A1       ; pop return address
  1076. >         MOVE.W  (SP)+,D0        ; data length
  1077. >         MOVE.L  (SP)+,D1        ; data address2
  1078. >         MOVE.L  (SP)+,A0        ; data address1
  1079. >         MOVEM.L A1/D1-D3, -(SP) ; save return address again
  1080. >
  1081. >         movea.l    d1,a1            ; copy data address2 into a1
  1082. >         move.w    d0,d1            ; copy data length
  1083. (begin mark)
  1084. >         beq.s    exit            ; skip if zero - result will be set to 0, not equal
  1085. >
  1086. >         clr.w    d0                ; initialise result to not equal
  1087. >         subq.w    #1,d1            ; decrement count for DBRA
  1088.  
  1089. > loop:    cmp.b    (a1)+,(a0)+        ; check string bytes
  1090. >         bne.s    exit            ; skip out if not equal
  1091. >         dbra    d1,loop            ; loop if more bytes
  1092. > noDiffs:
  1093. >         move.w    #1,d0            ; set result to 1 - strings are equal
  1094. (end mark)
  1095. > exit:
  1096. >         MOVEM.L (SP)+,A1/D1-D3  ; pop return address again
  1097. >         MOVE.W    D0,-(SP)        ; save result
  1098. >         JMP     (A1)            ; & split
  1099. >
  1100. >     ENDPROC
  1101.  
  1102. Here's my alternative to the sequence between (begin mark) and (end mark):
  1103.  
  1104.         clr.w    d0        ; clear high byte of result and init cond codes
  1105.         bra.s    endloop        ; enter loop at end
  1106. loop:        cmp.b    (a1)+, (a0)+
  1107. endloop:        dbne    d1, loop
  1108.         seq.b    d0
  1109.         neg.b    d0        ; result = 1 if equal, 0 if not
  1110.  
  1111. Note the way I enter the loop by jumping to the DBxx instruction. This
  1112. automatically adjusts for the fact that the termination condition is a count
  1113. of -1 rather than a count of zero, while simultaneously taking care of the
  1114. case where the length of the block was zero to begin with. See, there _is_
  1115. a reason why the DBxx instruction works the way it does.
  1116.  
  1117. Also note my use of a DBNE to loop and test for not equal at the same time.
  1118. However, since the loop is entered at the DBNE without an initial comparison,
  1119. you have to make sure the condition codes do *not* initially satisfy the
  1120. termination condition, or the DBcc will just fall through! Thus the CLR
  1121. instruction serves the dual purpose of setting the condition code Z bit, and
  1122. initializing the high byte of the result at the same time.
  1123.  
  1124. It is also possible to use a pair of DBRAs to handle a 32-bit unsigned
  1125. count, without sacrificing the speed of DBRA.
  1126.  
  1127. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  1128. Computer Services Dept                     fax: +64-7-838-4066
  1129. University of Waikato            electric mail: ldo@waikato.ac.nz
  1130. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  1131.  
  1132. +++++++++++++++++++++++++++
  1133.  
  1134. From: paul@cthq.UUCP (Paul G. Smith)
  1135. Date: 9 Jun 92 21:15:53 GMT
  1136. Organization: CommsTalk HQ
  1137.  
  1138.  
  1139. In article <2A33B3C5.52FE@deneva.sdd.trw.com> (comp.sys.mac.programmer), buckeye@spf.trw.com (John Wallace) writes:
  1140. > Sorry for rambling on so, but I do enjoy optimizing assembly code!
  1141.  
  1142. And I don't, regarding assembler programming as something to do only when
  1143. I have to, and not as an enjoyable task at all. 
  1144.  
  1145. Many thanks for the optimizations! I will make good use of them.
  1146.  
  1147. best regards, Paul
  1148.  
  1149. - -------------------------------------
  1150. Paul G Smith / CommsTalk HQ
  1151. INTERNET:  "paul@cthq.uucp"            CIX:  "pgsmith"
  1152. AppleLink: "commstalk.hq" ("commstalk.hq@applelink.apple.com")
  1153. tel/fax:   + 44 491 574295  (dial 11 on 2nd dial tone for fax)
  1154. snail:    40 St Marks Road, Henley-on-Thames, Oxon. RG9 1LW. UK
  1155.  
  1156. +++++++++++++++++++++++++++
  1157.  
  1158. From: paul@cthq.UUCP (Paul G. Smith)
  1159. Date: 9 Jun 92 21:15:58 GMT
  1160. Organization: CommsTalk HQ
  1161.  
  1162.  
  1163. In article <1992Jun9.114544.8513@waikato.ac.nz> (comp.sys.mac.programmer), ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes:
  1164. > Here's my alternative to the sequence between (begin mark) and (end mark):
  1165.  
  1166. Keep 'em coming! I'm learning a lot here. :-)
  1167.  
  1168. best regards, Paul
  1169.  
  1170. - -------------------------------------
  1171. Paul G Smith / CommsTalk HQ
  1172. INTERNET:  "paul@cthq.uucp"            CIX:  "pgsmith"
  1173. AppleLink: "commstalk.hq" ("commstalk.hq@applelink.apple.com")
  1174. tel/fax:   + 44 491 574295  (dial 11 on 2nd dial tone for fax)
  1175. snail:    40 St Marks Road, Henley-on-Thames, Oxon. RG9 1LW. UK
  1176.  
  1177. ---------------------------
  1178.  
  1179. End of C.S.M.P. Digest
  1180. **********************
  1181.